import { Controller, Get, Head, Params } from './decorator'
import {IRequestOption} from './type'

const fnDebugLog = require('debug')('controller')

@Controller('users')
export class UserController {
  @Get()
  getAll (option:IRequestOption) {
    fnDebugLog(`User::getAll - ${(this as any)?.root}`, option)
    return [
      { name: 'Tom',    age: '12'},
      { name: 'Jerry',  age: '11'},
    ]
  }

  @Get('vip')
  getVIP ( 
    // option:IRequestOption, 
    @Head('token') token: string, 
    @Params('name') name: string,
    @Head('app') app: string, 
  ) {
    fnDebugLog(`User::getVIP - ${(this as any)?.root}`, 'option')
    console.log(token, app, name)
    return [
      { name: 'King',   age: '32'},
      { name: 'Queen',  age: '31'},
    ]
  }
}

@Controller('teachers')
export class TeacherController {
  @Get()
  getAll (option:IRequestOption) {
    fnDebugLog(`Teacher::getAll - ${(this as any)?.root}`, option)
    return [
      { name: 'Mary', age: '32'},
      { name: 'Max',  age: '41'},
    ]
  }
}
